package database;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

public class Base {
	
	private Connection con;
	public static String USERNAME = "root";
	public static String PASSWORD = "";

	public void open() {
		String url = "jdbc:mysql://localhost:3306/";
		String dbName = "RegisterProduct?useUnicode=true&characterEncoding=utf-8";
		String driver = "com.mysql.jdbc.Driver";
		
		try {
			Class.forName(driver);
			this.con = DriverManager
					.getConnection(url + dbName, Base.USERNAME, Base.PASSWORD);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	public Connection getCon() {
		return con;
	}

	public void setCon(Connection con) {
		this.con = con;
	}

	public void close() {
		try {
			this.con.close();
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

}
